package com.nexgo.payment.util;

import android.text.TextUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

import java8.util.Optional;

/**
 * Created by xiaox on 2017/3/14.
 */

public class BankNameUtils {
    public static String getBankName(String bankCode) {
        if (TextUtils.isEmpty(bankCode)) return bankCode;
        try {
            Properties properties = new Properties();
            InputStream inputStream = BankNameUtils.class.getResourceAsStream("/assets/bank_code.properties");
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            properties.load(bufferedReader);
            return Optional.ofNullable(properties.getProperty(bankCode)).orElse(bankCode);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return bankCode;
    }
}
